Skip to content

Add check assert_type to tests for frame.py and add __new__ method for DatetimeIndex #1313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2025

Conversation

loicdiridollou
Copy link
Member

Cleaned up tests in tests/test_frame.py as there was no check assert_type in many places.
Added a new method for DatetimeIndex since it would not instantiate to DatetimeIndex but to Series[int].

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added: Please use assert_type() to assert the type of any return value

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for doing this. Caught a few things that we should clean up as a result.

Comment on lines 290 to 298
class _iAtIndexerFrame(_iAtIndexer, Generic[_T]):
def __getitem__(self, idx: tuple[int, int]) -> Scalar: ...
def __setitem__(
self,
idx: tuple[int, int],
value: Scalar | NAType | NaTType | None,
) -> None: ...

class _AtIndexerFrame(_AtIndexer, Generic[_T]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since none of the methods in either of these refer to _T, you can remove the Generic part.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I had duplicated the _LocIndexerFrame and was removing unused section but forgot about it.

def at(self): ... # Not sure what to do with this yet; look at source
def at(
self,
) -> _AtIndexerFrame: ... # Not sure what to do with this yet; look at source
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment

def iat(self): ... # Not sure what to do with this yet; look at source
def iat(
self,
) -> _iAtIndexerFrame: ... # Not sure what to do with this yet; look at source
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment

Comment on lines 3383 to 3384
df7: pd.DataFrame = pd.DataFrame({"x": [1, 2, 3]}, index=pd.Index(["a", "b", "c"]))
index: pd.Index = pd.Index(["b"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove the : pd.DataFrame and : pd.Index from this test

@loicdiridollou loicdiridollou requested a review from Dr-Irv August 12, 2025 21:30
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr-Irv Dr-Irv merged commit 6f479f6 into pandas-dev:main Aug 12, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants